/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package collections;

/**
 *
 * @author anonymous
 */

import java.util.*;
import java.util.Set;
public class Enumeraciones {
       // create an enum
   public static final int ADD = 1 << 0; // 1
   public static final int VIEW = 1 << 1; // 2
   public static final int DELETE = 1 << 2; // 4
   public static final int EDIT = 1 << 3; // 8
   
   public enum Permissions {
      ADD,
      VIEW, 
      DELETE, 
      EDIT
   };
   public static void main(String args[]){
       printPermissions( ADD | VIEW);
       System.out.println("TODOS");
       printPermissions( EnumSet.allOf(Permissions.class) );
       System.out.println("ALGUNOS SELECIONADOS");
       printPermissions( EnumSet.of(Permissions.DELETE, Permissions.EDIT) );
       System.out.println("RANGO");
       printPermissions( EnumSet.range(Permissions.ADD, Permissions.EDIT) );
       System.out.println("COMPLEMENTO");
       
       printPermissions( EnumSet.complementOf(EnumSet.of(Permissions.DELETE, Permissions.EDIT)) );
   }
   
   public static void printPermissions( int permissions) {
       if( (ADD & permissions) == ADD) {
           log("MONDAY");
       }
       if( (VIEW & permissions) == VIEW) {
           log("TUESDAY");
       }
       if( (DELETE & permissions) == DELETE) {
           log("WENDESNEY");
       }
   }
   
   public static void printPermissions( Set<Permissions> permissions) {
       for( Permissions day : permissions){
           log(day);
       }
   }
   
    public static void log(Object s){
        System.out.println(s);
    }
   
}
